home *** CD-ROM | disk | FTP | other *** search
- /*
- This file contains a generic initialization entry point for PPC CFuns.
- The prototypes in "callbackg.h" are used but the Code Fragment Manager
- links directly to the MathPadPPC routines. The "callbackg.c" interface
- routines are not needed.
-
- All the real work is done elsewhere by the routines:
-
- initialize()
- doevent(theEvent)
- dopredef()
- dofuncall(retval)
-
- This example uses all 4 possible entry points.
- The InitCFun() and dofuncall() entries are required for all CFuns.
- The dopredef() is used only if your CFun needs to reset something each time
- the doc is reevaluated. If it isn't used just pass a NULL to AddCfun().
- The handler() is used if your CFun needs access to events. If your CFun
- creates a window it must install a valid handler. If no handler is needed
- then don't call InstallEventHandler().
-
- InitCFun is the code fragment initialization entry point. This name must match the
- linker's initialization symbol name. The fragment has no main or termination routines.
-
- The call to FSpOpenResFile() is to allow a CFun access to resources from its own file
- during its initialize() routine. If your CFun doesn't need this access there is no
- need to open and close the resource file.
- */
-
- #include <CodeFragments.h>
- #include "callbackg.h" /* prototypes for callbacks */
- #include "CFundef.h" /* prototypes for routines specific to this CFun */
-
- OSErr InitCFun(CFragInitBlockPtr iblk);
-
- OSErr InitCFun(CFragInitBlockPtr iblk)
- {
- FSSpecPtr fspec;
- int ref;
-
- AddCFun(FUNNAME,FUNPARMS,&dofuncall,&dopredef);
- InstallEventHandler(&doevent);
- fspec = iblk->fragLocator.u.onDisk.fileSpec; // get this fragment's FSspec
- ref = FSpOpenResFile(fspec,fsCurPerm);
- initialize();
- CloseResFile(ref);
- return noErr;
- }
-